import unittest
from function import count_characters, count_words, count_sentences, count_code_lines

class MyTest(unittest.TestCase):
    def test_count_characters(self):
        # 测试count_characters函数
        file_path = 'D:\\VscodeWorkspace\\Python\\Statistics\\Hw\\TestMaterial\\Uint_Test.txt'
        result = count_characters(file_path)
        self.assertEqual(result, 82)  
        # 文件Uint_Test.txt包含79个字符

    def test_count_words(self):
        # 测试count_words函数
        file_path = 'D:\\VscodeWorkspace\\Python\\Statistics\\Hw\\TestMaterial\\Uint_Test.txt'
        result = count_words(file_path)
        self.assertEqual(result, 14)  
        # 文件Uint_Test.txt包含14个单词

    def test_count_sentences(self):
        # 测试count_sentences函数
        file_path = 'D:\\VscodeWorkspace\\Python\\Statistics\\Hw\\TestMaterial\\Uint_Test.txt'
        result = count_sentences(file_path)
        self.assertEqual(result, 2)  
        # 文件Uint_Test.txt包含1个句子

    def test_count_code_lines(self):
        # 测试count_code_lines函数
        file_path = 'D:\\VscodeWorkspace\\Python\\Statistics\\Hw\\TestMaterial\\Uint_Test.txt'
        result = count_code_lines(file_path)
        self.assertEqual(result, (5, 3, 2))  
        # 文件Uint_Test.txt包含20行代码、5行空行、3行注释


if __name__ == '__main__':
    unittest.main()